import _axios from '@/api/axios';
import { gFunc } from "@/plugins/gFunc";
import { pathMap } from "@/pathMap";

export const state = () => ({
    token: '',
    loginOverTime: '',
    user: {},
    apiPass: true
})
  
export const mutations = {
    saveToken(state, login){
        console.log(login);
        state.token = login.access_token
        state.loginOverTime = login.expires_in
        localStorage.setItem('token', state.token)
        localStorage.setItem('loginOverTime', state.loginOverTime)
    },
    saveUser(state, user){
        console.log('user', user);
        Object.keys(user).forEach((key)=>{
            state.user[key] = user[key]
        })
        // console.log('state', state.user);
        // //console.log(this);

    },
    clearLogin(state){
        state.user = {}
        state.token = '',
        state.loginOverTime = 0
        localStorage.clear()
    },

}